<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        let url = 'https://cn.bing.com/search?q=aaa&form=ANNTH1&refig=2df09095b1ee42ffb9958d7720efec2f'
        function myQueryURLParameter1(url) {
            let a = url.split('?')[1]
            let b = a.split('&')
            let obj = {}
            for(let i = 0;i < b.length;i++) {
                let param = b[i].split('=')
                obj[param[0]] = param[1]
            }
            return obj
        }
        console.log(myQueryURLParameter1(url));
        function myQueryURLParameter2(url) {
            let reg = /(([^&=?]+)=([^&=?]+))/g,obj = {}
            url.replace(reg,function(){
                // console.log(arguments);
                obj[arguments[2]] = arguments[3]
            })
            return obj
        }
        console.log(myQueryURLParameter2(url));
        String.prototype.myQueryURLParameter = function () {
            let reg = /(([^&=?]+)=([^&=?]+))/g,
                obj = {}
            this.replace(reg, (...arg) => {
                obj[arg[2]] = arg[3]
            })
            return obj
        }
        console.log(url.myQueryURLParameter());
        const a = {
            name: 'zs',
            age: 20
        }
        function getPerson(person) {
            person.name = 'lisi'
            const age = 18
            return {name:person.name,age}
        }
        const b = getPerson(a)
        console.log(a);
        console.log(b);
    </script>
</body>

</html>